package com.lotterymanage.web.controller;

import com.lotterymanage.domain.UserRootin;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.lotterymanage.domain.User;
import com.lotterymanage.domain.UserGroup;
import com.lotterymanage.page.Pagination;
import com.lotterymanage.service.UserGroupService;
import com.lotterymanage.service.UserRootinService;
import com.lotterymanage.service.UserService;

/**
 * 用户管理.
 * @author lxz
 * @date Apr 22, 2010
 */
@Controller
@RequestMapping("/UserController.do")
public class UserController extends BaseController {

    @Autowired
    private UserService userService;
    @Autowired
    private UserGroupService userGroupService;
    @Autowired
    private UserRootinService userRootinService;

    /**
     * 彩民列表.
     * @param request HttpServletRequest
     * @param result BindingResult
     * @param model ModelMap
     * @param user User
     * @return userList
     */
    @RequestMapping(params = "method=getAllUser")
    public String getAllUser(@ModelAttribute("user") final User user,
            final BindingResult result, final ModelMap model, final HttpServletRequest request) {
        //用户来源
        List<UserRootin> userRootinList = userRootinService.getUserRootin();
        model.put("userRootinList", userRootinList);
        //用户组列表
        List<UserGroup> userGroupList = userGroupService.findAll();
        model.put("userGroupList", userGroupList);
        //用户分页列表
        user.setShownum(5);
        Pagination page = this.userService.findPage(user);
        model.put("page", page);
        return "userList";
    }
}
